//
//  HLTabBarController.m
//  app.main
//
//  Created by 胡林虎 on 2017/6/26.
//  Copyright © 2017年 胡林虎. All rights reserved.
//

#import "HLTabBarController.h"

#import <app_home/HLHomeController.h>
#import <app_infor/HLInforController.h>
#import <app_find/HLFindController.h>
#import <app_mine/HLMineController.h>

@interface HLTabBarController ()

@end

@implementation HLTabBarController

- (instancetype)init {
    if (self = [super init]) {
        [self initTabs];
        
    }
    return self;
}


- (void)initTabs {
    
    self.view.backgroundColor  = [UIColor yellowColor];
    
    
    NSArray *items = @[@{@"id": @"HLHomeController",
                         @"title":@"首页",
                         @"img_no":@"tabbar0",
                         @"img_sel":@"tabbar0_sel"
                         },
                       @{@"id": @"HLInforController",
                         @"title":@"信息",
                         @"img_no":@"tabbar1",
                         @"img_sel":@"tabbar1_sel"
                         },
                       @{@"id": @"HLFindController",
                         @"title":@"发现",
                         @"img_no":@"tabbar2",
                         @"img_sel":@"tabbar2_sel"
                         },
                       @{@"id": @"HLMineController",
                         @"title":@"个人",
                         @"img_no":@"tabbar3",
                         @"img_sel":@"tabbar3_sel"
                         }
                       ];
 
    NSMutableArray *controllers = [NSMutableArray arrayWithCapacity:items.count];
    
    for (NSDictionary *item in items) {
        NSString *itemName = item[@"id"];
        NSString *title = item[@"title"];
        NSString *noImage = item[@"img_no"];
        NSString *selImage = item[@"img_sel"];
        
        Class classVC = NSClassFromString(itemName);
        UIViewController *controller =  [[classVC alloc] init];
        controller.title = title;
        controller.tabBarItem.title = title;
        controller.tabBarItem.image = [UIImage imageNamed:noImage];
        controller.tabBarItem.selectedImage = [UIImage imageNamed:selImage];
        [controllers addObject:controller];
    
    }

    self.viewControllers = controllers;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
